package com.sun.showcase.controller.basic;

import com.sun.showcase.biz.basic.service.BaseseCodingRuleService;
import com.sun.showcase.client.domain.basic.BaseseCodingRule;
import com.sun.showcase.client.query.basic.BaseseCodingRuleQuery;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value="/basic/baseseCodingRule")
public class BaseseCodingRuleController {
	
	@Autowired
	private BaseseCodingRuleService baseseCodingRuleService;
	
	private Result json = new Result();
	
	/**
	 * 跳转到BaseseCodingRule管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value = "/goBaseseCodingRule")
	public String goBaseseCodingRule() {
		return "basic/baseseCodingRule";
	}
	/**
	 * 跳转到BaseseCodingRule编辑页面
	 * 
	 * @return
	 */
	public String handleBaseseCodingRule() {
		return "handle";
	}
	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/showDesc")
	public BaseseCodingRule showDesc(BaseseCodingRuleQuery baseseCodingRuleQuery) {
		return baseseCodingRuleService.get(baseseCodingRuleQuery);
	}

	/**
	 * 获得pageHotel数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(BaseseCodingRuleQuery baseseCodingRuleQuery) {
		return baseseCodingRuleService.datagrid(baseseCodingRuleQuery);
	}
	
	
	/**
	 * 获得无分页的所有数据
	 */
	@ResponseBody
	@RequestMapping(value = "/combox")
	public List<BaseseCodingRuleQuery> combox(BaseseCodingRuleQuery baseseCodingRuleQuery){
		return baseseCodingRuleService.listAll(baseseCodingRuleQuery);
	}

	/**
	 * 添加一个BaseseCodingRule
	 */
	@ResponseBody
	@RequestMapping(value = "/add")
	public Result add(BaseseCodingRuleQuery baseseCodingRuleQuery) {
		baseseCodingRuleService.add(baseseCodingRuleQuery);
		json.setSuccess(true);
		json.setMsg("添加成功！");
		return json;
	}

	/**
	 * 编辑BaseseCodingRule
	 */
	@ResponseBody
	@RequestMapping(value = "/edit")
	public Result edit(BaseseCodingRuleQuery baseseCodingRuleQuery) {
		baseseCodingRuleService.updateEdit(baseseCodingRuleQuery);
		json.setSuccess(true);
		json.setData(baseseCodingRuleQuery);
		json.setMsg("编辑成功！");
		return json;
	}

	/**
	 * 物理删除BaseseCodingRule
	 */
	@ResponseBody
	@RequestMapping(value = "/delete")
	public Result delete(BaseseCodingRuleQuery baseseCodingRuleQuery) {
		baseseCodingRuleService.delete(baseseCodingRuleQuery.getIds());
		json.setSuccess(true);
		return json;
	}
	
	/**
	 * 逻辑删除BaseseCodingRule
	 */
	@ResponseBody
	@RequestMapping(value = "/deletePt")
	public Result deletePt(BaseseCodingRuleQuery baseseCodingRuleQuery) {
		baseseCodingRuleService.deletePt(baseseCodingRuleQuery.getIds());
		json.setSuccess(true);
		return json;
	}

	/**
	 * 查询下一个编码
	 */
	@ResponseBody
	@RequestMapping(value = "/getNextCode")
	public String getNextCode(Long id) {
		return baseseCodingRuleService.getNextCodeById(id);
	}
	
}
